<extend name="_layout/main"/>
<block name="head">

</block>
<block name="top">

</block>
<block name="content">
    <div class="login clearfloat box-s">
        <h3>会员注册</h3>
        <div class="list clearfloat">
            <ul>
                <li class="ra3">
                    <p class="fl clearfloat">
                        <span class="opa5"></span>
                        <i class="iconfont icon-yonghuming"></i>
                    </p>
                    <div class="nr clearfloat fl">
                        <span class="opa3"></span>
                        <input type="text" name="username" id="username" placeholder="用户姓名"/>
                    </div>
                </li>
                <li class="ra3">
                    <p class="fl clearfloat">
                        <span class="opa5"></span>
                        <i class="iconfont icon-mima"></i>
                    </p>
                    <div class="nr clearfloat fl">
                        <span class="opa3"></span>
                        <input type="password" name="password" id="password" placeholder="登录密码"/>
                    </div>
                </li>
                <li class="ra3">
                    <p class="fl clearfloat">
                        <span class="opa5"></span>
                        <i class="iconfont icon-shouji"></i>
                    </p>
                    <div class="nr clearfloat fl">
                        <span class="opa3"></span>
                        <input type="text" name="mobile" id="mobile" value="" placeholder="手机号"/>
                    </div>
                </li>
                <li class="ra3">
                    <p class="fl clearfloat">
                        <span class="opa5"></span>
                        <i class="iconfont icon-shenfenzheng"></i>
                    </p>
                    <div class="nr clearfloat fl">
                        <span class="opa3"></span>
                        <input type="text" name="id_number" id="id_number" placeholder="身份证号"/>
                    </div>
                </li>
                <li class="ra3">
                    <p class="fl clearfloat">
                        <span class="opa5"></span>
                        <i class="iconfont icon-tuijianrenyaoqing"></i>
                    </p>
                    <div class="nr clearfloat fl">
                        <span class="opa3"></span>
                        <input type="text" name="inviter" id="inviter" value="{$inviter}" placeholder="推荐人账户"/>
                    </div>
                </li>
                <li class="ra3">
                    <p class="fl clearfloat">
                        <span class="opa5"></span>
                        <i class="iconfont icon-yanzhengma"></i>
                    </p>
                    <div class="nr nrtwo clearfloat fl">
                        <span class="opa3"></span>
                        <input type="text" name="captcha" id="captcha" placeholder="验证码"/>
                        <samp class="db fr"><img src="{:U('Captcha/show')}" id="imgcaptcha"/> </samp>
                    </div>
                </li>
            </ul>
        </div>
        <div class="login-btn">
            <a href="javascript:void(0)" id="btn-register">
                注册
            </a>
        </div>
        <div class="mima mimaone clearfloat">
            <ul>
                <li class="fr">
                    <a href="{:U('/login')}">立即登录</a>
                </li>
            </ul>
        </div>
    </div>
</block>
<block name="scripts">
    <script>
        $(document).on('click', '#imgcaptcha', function (e) {
            var url = "{:U('Captcha/show')}" + '?' + Math.random();
            $(this).attr('src', url);
        })

        $(document).on('click', '#btn-register', function (e) {
            e.preventDefault();
            var username = $("#username").val();
            var password = $("#password").val();
            var mobile = $("#mobile").val();
            var id_number = $('#id_number').val();
            var inviter = $("#inviter").val();
            var captcha = $("#captcha").val();
            if (!username || username == '') {
                mui.alert('请输入用户名');
                return;
            }
            if (!password || password == '') {
                mui.alert('请输入密码');
                return;
            }
            if (!mobile || mobile == '') {
                mui.alert('请输入手机号');
                return;
            }
            if (!id_number || id_number == '') {
                mui.alert('请输入身份证号');
                return;
            }
            if (!inviter || inviter == '') {
                mui.alert('请输入推荐人账号');
                return;
            }
            if (!captcha || captcha == '') {
                mui.alert('请输验证码');
                return;
            }
            var data = {};
            data.username = username;
            data.password = password;
            data.mobile = mobile;
            data.id_number = id_number;
            data.inviter = inviter;
            data.captcha = captcha;

            $.post(self.location, data, function (xdata) {
                mui.toast(xdata.info);
                if (xdata.status == '1') {
                    setTimeout(function () {
                        document.location.href = xdata.url;
                    }, 1000)
                }
            }, 'json');
        })
    </script>
</block>